package exception;

public class TryCatchDemo {
    public static void main(String[] args) {
        /*
        System.out.println("程序开始了。。。");

        try{
            String line = null;
            System.out.println(line.length());
        }catch (NullPointerException s){
            System.out.println("出现了空指针异常并解决了");
            //针对try中出现空指针异常的解决办法
        }
        System.out.println("程序结束了....");
         */
        System.out.println("程序开始了....");
        try{
            String line = "abc";
            System.out.println(line.charAt(2));
        //}catch (NullPointerException s){
          //  System.out.println("出现了空指针异常并解决");
        }catch (NullPointerException|StringIndexOutOfBoundsException s){
            System.out.println("出现了字符串下标越界异常并解决了");
        //}catch (Exception s){
            // System.out.println("反正就是出了个错并解决了");
        }
        System.out.println("程序结束了.....");
    }

}
